//当前是路由配置
import { api } from "./apiOption.js";

// const getStepsEffect = function (to, from) {
//   let steps = this.userInfo.steps, isOld, verify;
//   if (!steps) return false;
//   verify = this.$pOption[to.name].verify || {};
//   if (!verify.wizard) return false;
//   isOld = this.isBeforeStep(from.name, {name: to.name});
//   return isOld ? "left" : 'right';
// };
const OPTION = [
  {
    path: "/",
    redirect: "/home"
  },
  {


    path: "/home",
    name: "home",
    meta: {
      title: '首页',
    },
    component: () =>
      import( /* webpackChunkName: "home" */ "@/views/home/home.vue")
  },
  {
    meta: {
      title: '公告',
    },
    path: "/notice",
    name: "notice",
    component: () =>
      import( /* webpackChunkName: "home" */ "@/views/notice/notice.vue")
  },

  {
    meta: {
      title: '公告详情',
    },
    path: "/noticeDetails",
    name: "noticeDetails",
    component: () =>
      import(
        /* webpackChunkName: "home" */
        "@/views/noticeDetails/noticeDetails.vue"
      )
  },
  {
    meta: {
      title: '商品列表',
    },
    path: "/goods",
    name: "goods",
    component: () => import("@/views/goods/goods.vue")
  },
  {
    meta: {
      title: '商品详情',
    },
    path: "/goodDetails",
    name: "goodDetails",
    component: () => import("@/views/goodDetails/goodDetails.vue")
  },
  {
    meta: {
      title: '我的',
    },
    path: "/personalCenter",
    name: "personalCenter",
    component: () => import("@/views/personalCenter/personalCenter.vue")
  },
  {
    meta: {
      title: '地址',
    },
    path: "/address",
    name: "address",
    component: () => import("@/views/personalCenter/address.vue")
  },
  {
    meta: {
      title: '地址编辑',
    },
    path: "/addressEdit",
    name: "addressEdit",
    component: () => import("@/views/personalCenter/addressEdit.vue")
  },
  {
    meta: {
      title: '地址新增',
    },
    path: "/addressAdd",
    name: "addressAdd",
    component: () => import("@/views/personalCenter/addressEdit.vue")
  },

  {
    meta: {
      title: '设置',
    },
    path: "/oauth",
    name: "oauth",
    component: () => import("@/views/personalCenter/oauth.vue")
  },
  // {
  //   title: "修改密码",
  //   path: "/updatePassword",
  //   name: "updatePassword",
  //   component: () => import("@/views/personalCenter/updatePassword.vue")
  // },
  {
    meta: {
      title: '授权',
    },
    path: "/oauthSure",
    name: "oauthSure",
    component: () => import("@/views/personalCenter/oauthSure.vue")
  },
  {
    meta: {
      title: '支付',
    },
    path: "/payment",
    name: "payment",
    component: () => import("@/views/pay/pay.vue")
  },
  {
    meta: {
      title: '订单列表',
    },
    path: "/order",
    name: "order",
    component: () => import("@/views/order/order.vue")
  },
  {
    meta: {
      title: '订单详情',
    },
    path: "/orderDetails",
    name: "orderDetails",
    component: () => import("@/views/order/orderDetails.vue")
  },


  {
    meta: {
      title: '登录',
    },
    path: "/login",
    name: "login",
    component: () =>
      import( /* webpackChunkName: "home" */ "@/views/login/login.vue")
  },
  {
    meta: {
      title: '注册',
    },
    path: "/register",
    name: "register",
    component: () =>
      import( /* webpackChunkName: "home" */ "@/views/login/register.vue")
  },
  {
    meta: {
      title: '用户协议',
    },
    path: "/agreement",
    name: "agreement",
    component: () =>
      import( /* webpackChunkName: "home" */ "@/views/agreement/agreement.vue")
  },

  {
    meta: {
      title: '404',
    },
    path: "*",
    name: "error",
    component: () =>
      import( /* webpackChunkName: "House" */ "@/views/errorTo404/index.vue")
  }
];

const pageOption = function() {
  this.cache = OPTION;
};
pageOption.prototype.add = function(option) {
  this.cache.concat(option);
};
pageOption.prototype.getOption = function() {
  var option = {},
    name;
  for (let i = 0; i < this.cache.length; i++) {
    if ((name = this.cache[i].name)) {
      option[name] = this.cache[i];
    }
  }
  return option;
};
const PO = new pageOption();

export const POInstall = {
  install(vue) {
    vue.prototype.$pOption = PO.getOption();
    vue.prototype.$api = api;
  }
};
export const pOption = PO.cache;